(function($) {

	$(document).ready(function() {
			if ($("#main-tab").length > 0 )
			{
				$( "#main-tab" ).tabs({
					  	active   : $.cookie('activetab'),
					    activate : function( event, ui ){
					        $.cookie( 'activetab', ui.newTab.index(),{
					            expires : 10
					        });
					    }
				});
			}

			if ($(".inner-tab").length > 0 )
			{
				$( ".inner-tab" ).tabs({
					active   : $.cookie('activeinnertab'),
				    activate : function( event, ui ){
				        $.cookie( 'activeinnertab', ui.newTab.index(),{
				            expires : 10
				        });
				    }
				});
			}
			
			if ($("#accordion").length > 0 )
			{
				$( "#accordion" ).accordion();
			}

			// if ($("#checker.slider input").length > 0)
			// {
			

			// }

			var formSocial1 =  '<div class="form-group item form-social fix-form wrap-social">\
                                  	<a class="icon thickbox available-panel"href="#TB_inline?width=600&height=550&inlineId=table-fa"><i class="fa fa-refresh"></i></a>\
                                  	<input type="hidden" name="theme_options[footer][social][social_icon][]" value="fa fa-refresh">\
                                  	<input type="text" name="theme_options[footer][social][social_link][]" value="" placeholder="Link">\
                                  	<a class="remove-socials" data-class="remove"><i class="fa fa-times"></i></a>\
                               </div>';

			$(".wo-footer-addsocial").on("click", function(event)
			{
				event.preventDefault();
				

                $(this).parents(".wo-add-social").before(formSocial1);                   
			})

			$(".remove-socials").live("click", function(event)
			{
				event.preventDefault();
				$(this).parents(".wo-footer-socials").fadeOut("slow", function(){$(this).remove()});

	
				if ( ($(".wo-footer-socials").length == 1) )
				{
					$(".wo-add-social").before(formSocial1);         
				}
			})

			

		$("input[type=checkbox]").switchButton(
			{
	          width: 60,
	          height: 30,
	          button_width: 30,
	          checked: true
	        });	

	    // order section
	 	$(".section-order-reset").on("click",function(){
           $("#sortable input").val("ourservices, aboutus, ourteam, ourwork, ourclients, contact");
           var order = ['ourservices', 'aboutus', 'ourteam', 'ourwork', 'ourclients', 'contact'];
           for(var i=0;i<order.length;i++)
           {
               $("li[data-name='"+order[i]+"']").detach().appendTo("#sortable");
           }
           return false;
        });

	 	if ($("#sortable").length>0)
	 	{
	 		$("#sortable").sortable(
	 		{
	 			update: function(event, ui) {
                    var order = [];
                    $('#sortable li').each( function(e) {
                        order.push( $(this).attr('data-name'));
                    });
                    // join the array as single variable...
                    var positions = order.join(',');
                    $("input.section-order").val( positions );
                    return true;
                }
	 		})

	 		$( "#sortable" ).disableSelection();
	 	}	

	});
	
	// alert("a");

})(jQuery);	